package com.founder.gateway.system.thread;

import java.util.Date;
import java.util.Timer;

import org.setu.framework.core.properties.SetuSystemUtil;
import org.setu.framework.log.SetuLogMonitor;
import org.setu.framework.timetask.AbstractTimerTask;
import org.setu.framework.timetask.TimerUtil;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;
/**
 * 日志处理定时器
 * @author 胡飞龙
 *
 */
@Component
public  class SetuLogTimerTask extends AbstractTimerTask implements ApplicationRunner{
	public static  Timer timer = new Timer();
	@Override
	public void run() {
		try {
			SetuLogMonitor.execute();
		}catch(Exception e) {
			e.printStackTrace();
		}
	}
	public static void execute(){
		if(SetuSystemUtil.logHandler&&SetuLogMonitor.isAllowed){
			timer=TimerUtil.runTimeTaskB(new Date(), SetuSystemUtil.logPeriod, new SetuLogTimerTask());
		}
	}
	@Override
	public void run(ApplicationArguments args) throws Exception {
		SetuLogTimerTask.execute();
		
	}

}
